MediaStore.Video-query

MediaStore.Video
static final Cursor query(ContentResolver cr, Uri uri, String[] projection)

1
2
3
4
5
6
7
8
9
10
private void fetchVideoList() {
String[] columns = {
MediaStore.Video.VideoColumns._ID,
MediaStore.Video.VideoColumns.TITLE,
MediaStore.Video.VideoColumns.ARTIST
};
Cursor list = MediaStore.Video.query(getContentResolver(),
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns);
Log.i(TAG, "count: " + list.getCount());
}

比较:
ContentResolver public final @Nullable Cursor query(@RequiresPermission.Read @NonNull Uri uri,
@Nullable String[] projection, @Nullable String selection,
@Nullable String[] selectionArgs, @Nullable String sortOrder)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class	MediaStore.Video.Media
class MediaStore.Video.Thumbnails
参考:http://blog.csdn.net/chenjie19891104/article/details/6338910
String[] thumbColumns = new String[]{
MediaStore.Video.Thumbnails.DATA,
MediaStore.Video.Thumbnails.VIDEO_ID
};

String[] mediaColumns = new String[]{
MediaStore.Video.Media.DATA,
MediaStore.Video.Media._ID,
MediaStore.Video.Media.TITLE,
MediaStore.Video.Media.MIME_TYPE
};
https://stackoverflow.com/questions/20517687/mediastore-video-thumbnails-getthumbnail?lq=1
MediaStore.Video.Thumbnails
public static Bitmap getThumbnail (ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options)
http://www.jianshu.com/p/498c9d06c193
Android读取本地照片和视频相册

异常情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such column: _display_name (code 1): , while compiling: SELECT _id, _data FROM videothumbnails ORDER BY _display_name)
#################################################################)
#################################################################
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:489)
at android.content.ContentResolver.query(ContentResolver.java:433)
at android.provider.MediaStore$Video.query(MediaStore.java:1965)
at work.wangxiang.lansodemo.LansoDemoActivity.fetchVideoList(LansoDemoActivity.java:148)
at work.wangxiang.lansodemo.LansoDemoActivity.onTest(LansoDemoActivity.java:106)

Cursor list = MediaStore.Video.query(getContentResolver(),
MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, thumbColumns);

ref

Android - MediaStore.Video.query() is returning null
开源例子